/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package persistence;
import java.sql.Connection;
import java.sql.Date;
import model.Cliente;  
import java.sql.*;
import persistence.ConnectionFactory;
import java.sql.PreparedStatement;
import model.Usuario;
import model.Pedido;
/**
 *
 * @author Clau
 */
public class PedidoDAO extends Dao{
    private final Connection connection;
   private Usuario usuario;
    private Cliente cliente;
    private String produto;
    private int tipo;
    private String modelo;
    private String fabricante;
    private String descricaoProblema;
    private java.util.Date dtEntrada;
    private java.util.Date dtEntrega;
    private double preco;
    private int statusPedido;

public PedidoDAO(){
    this.connection = new ConnectionFactory().getConnection();
}


    @Override
    protected void open() throws Exception {
        super.open(); //To change body of generated methods, choose Tools | Templates.
    }

public void adiciona (Pedido pedido) throws SQLException {
    stmt = con.prepareStatement("INSERT INTO pedido(produto,tipo,modelo,fabricante,descricaoProblema,dtEntrada,dtEntrega,preco,statusPedido) VALUES(?,?,?,?,?,?,?,?,?)");
    try{
        stmt.setString(1, pedido.getProduto());
        stmt.setInt(2, pedido.getTipo());
        stmt.setString(3, pedido.getModelo());
        stmt.setString(4, pedido.getFabricante());
        stmt.setString(5, pedido.getDescricaoProblema());
        stmt.setDate(6, (Date) pedido.getDtEntrada());
        stmt.setDate(7, (Date) pedido.getDtEntrega());
        stmt.setDouble(8, pedido.getPreco());
        stmt.setInt(9, pedido.getStatusPedido());
    }catch (SQLException u){
        throw new RuntimeException (u);
    }

}

    @Override
    protected void close() throws Exception {
        super.close(); //To change body of generated methods, choose Tools | Templates.
    }

}

